//
//  LightningLiftViewController.m
//  PlayerWorld
//
//  Created by 1 on 16/5/1.
//  Copyright © 2016年 刘成. All rights reserved.
//
#define UISCREEN_WIDTH  [UIScreen mainScreen].bounds.size.width
#define UISCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

#import "LightningLiftViewController.h"

@interface LightningLiftViewController ()<UITextFieldDelegate>

@end

@implementation LightningLiftViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor yellowColor];
    self.tabBarController.tabBar.hidden = YES;
    self.title = @"提现";
    
    self.LightningLifttitles1 = @[@"绑定银行：",@"绑定卡号：",@"取款姓名：",@"开户地址：",@"当前余额："];
    self.LightningLifttitles2 = @[@"中国工商银行",@"**************35",@"何**",@"浙江省杭州市天目山路",@"25189.00元"];

    LightningLifttableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH, UISCREEN_HEIGHT) style:UITableViewStylePlain];
    LightningLifttableView.dataSource = self;
    LightningLifttableView.delegate = self;
//    [LightningLifttableView registerNib:[UINib nibWithNibName:@"TableViewCell" bundle:nil]  forCellReuseIdentifier:@"cell"];
    LightningLifttableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view addSubview:LightningLifttableView];

    
}

- (CGFloat)tableView:(UITableView *)atableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 40;
}


//设置表视图中的行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return [_LightningLifttitles1 count];
    } else if(section == 1){
        return 2;
    }else {
        return 1;
    }
}
//设置表视图中的section（分组）数,默认为1
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 3;
}
// 设置header的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20;
}

//设置单元格中的数据
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellIdent = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdent];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdent];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        UILabel *bettingInformationLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, (40-30)/2, 200, 30)];
        bettingInformationLabel.tag = 104;
        bettingInformationLabel.textColor = [UIColor blackColor];
//        bettingInformationLabel.font = [UIFont systemFontOfSize:16];
        [cell.contentView addSubview:bettingInformationLabel];

        
        UITextField *setUpMoneyPasswordTextField = [[UITextField alloc]initWithFrame:CGRectMake(100, (40-30)/2, UISCREEN_WIDTH-100, 30)];
        setUpMoneyPasswordTextField.returnKeyType = UIReturnKeyDone;  //返回按钮的样式
        setUpMoneyPasswordTextField.clearButtonMode = YES; //清除模式开启
        setUpMoneyPasswordTextField.secureTextEntry = YES; //密码输入框
        //协议执行者交给textField自己self
        setUpMoneyPasswordTextField.delegate = self;
        setUpMoneyPasswordTextField.tag = 105;
        [cell.contentView addSubview:setUpMoneyPasswordTextField];

        
    }
    UILabel *bettingInformationLabel = (UILabel *)[cell.contentView viewWithTag:104];
    UITextField *setUpMoneyPasswordTextField = (UITextField *)[cell.contentView viewWithTag:105];
    
    
    //设置数据
    if (indexPath.section == 0) {
        
//        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@:  中国工商银行",_LightningLifttitles1[indexPath.row]]];
//        [str setAttributes:@{NSForegroundColorAttributeName:[UIColor greenColor],NSFontAttributeName:[UIFont systemFontOfSize:12]} range:NSMakeRange(0, 5)];
//        cell.textLabel.text =str;
        
        cell.textLabel.text = _LightningLifttitles1[indexPath.row];
        cell.textLabel.textColor = [UIColor grayColor];
        setUpMoneyPasswordTextField.hidden = YES;
        bettingInformationLabel.hidden = NO;
        bettingInformationLabel.text = _LightningLifttitles2[indexPath.row];
        
     }else  if (indexPath.section == 1 & indexPath.row == 0){
         
         bettingInformationLabel.hidden = YES;
        setUpMoneyPasswordTextField.hidden = NO;
        setUpMoneyPasswordTextField.placeholder = @"请输入取款密码";
        cell.textLabel.text = @"取款金额";
         
     }else  if (indexPath.section == 1 & indexPath.row == 1){
         
         bettingInformationLabel.hidden = YES;
         setUpMoneyPasswordTextField.hidden = NO;
        cell.textLabel.text = @"资金密码";
         
     }else{
         cell.textLabel.text = @"确认取款";
         cell.textLabel.textAlignment = NSTextAlignmentCenter;
         cell.textLabel.textColor = [UIColor whiteColor];
         cell.backgroundColor = [UIColor colorWithRed:48/255.0f green:173/255.0f blue:224/255.0f alpha:1];
         setUpMoneyPasswordTextField.hidden = YES;
         bettingInformationLabel.hidden = YES;
     }
    return cell;
}
//单元格点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
//    LotteryDetailsViewController *lDVC= [[LotteryDetailsViewController alloc] init];
//    [self.navigationController pushViewController:lDVC animated:YES];
    
}

@end
